﻿using System; 
using System.Collections.Generic; 
using System.ComponentModel; 

namespace DataAccess{
[Serializable]
[GenWiseAttribute(IsDataSourceEntity = true) ]
public class art_type : INotifyPropertyChanged
 {


#region --- Class Fields / Objects  ---

[NonSerialized]
protected PropertyChangedEventHandler _propertyChanged;
private System.Int32 _id;
private System.String _label;
private System.String _name;
private IList<art> _arts;
private IList<topRated> _topRateds;

#endregion


#region --- Class Properties ---

public virtual System.Int32 id 
{
get
{
return _id;
}
}

public virtual System.String label 
{
get
{
return _label;
}
set 
{
if ( _label != value) 
{
_label = value ;
OnPropertyChanged("label");
}
}
}

public virtual System.String name 
{
get
{
return _name;
}
set 
{
if ( _name != value) 
{
_name = value ;
OnPropertyChanged("name");
}
}
}

/// <summary>
/// Collection of art.
/// </summary>
/// <remarks>
/// This has been automatically being generated because of the mapped 1:Many Relation 
/// </remarks>
[GenWiseAttribute(RelationID = "4d986693-4178-4e49-b16d-f130d50304b2" , CollectionOfType = typeof(art)) ]
public virtual IList<art> arts 
{
get
{
 if (_arts == null) _arts = new List<art>();

return _arts;
}
set 
{
if ( _arts != value) 
{
_arts = value ;
}
}
}

/// <summary>
/// Collection of topRated.
/// </summary>
/// <remarks>
/// This has been automatically being generated because of the mapped 1:Many Relation 
/// </remarks>
[GenWiseAttribute(RelationID = "9147e615-d081-4d15-b52d-f0a093cb9329" , CollectionOfType = typeof(topRated)) ]
public virtual IList<topRated> topRateds 
{
get
{
 if (_topRateds == null) _topRateds = new List<topRated>();

return _topRateds;
}
set 
{
if ( _topRateds != value) 
{
_topRateds = value ;
}
}
}

/// <summary>
/// Is this object Valid? 
/// </summary>
/// <remarks>
/// This is achieved by counting how many errors are returned from the Validate() method. If no errors are found then it's valid.
/// </remarks>
[Bindable(false)]
public virtual System.Boolean IsValid 
{
get
{
List<Error> _errors = this.Validate(); if ( _errors.Count > 0 ) return false; else return true;
}
}


#endregion


#region --- Class Methods --- 

/// <summary>
/// Raises PropertyChanged event.
/// </summary>
protected virtual void OnPropertyChanged(System.String ppropertyChanged)
{
if (_propertyChanged != null) _propertyChanged( this , new PropertyChangedEventArgs(ppropertyChanged));

}

/// <summary>
/// Create a new art_type object. 
/// </summary>
public  art_type()
{
_id = System.Int32.MinValue;

}

/// <summary>
/// Add a new art object and automatically associate it with this instance as it's parent. This method makes easier to add new children and ensures you do not forget to related them correctly.
/// </summary>
///<param name="part">An art object to be added to this objects collection.</param>
public virtual void Addart(art part)
{
if( part == null  ) throw new ArgumentNullException("part");
// Set the Parent Property
part.art_type = this;
if (!part.IsValid) { throw new Exception("part failed on the Validate() method." + Error.ErrorsToString( part.Validate() ) ); }
arts.Add(part);
}

/// <summary>
/// Delete an existing art object + remove the association it with this instance as it's parent. This method makes easier to add new children and ensures you do not forget to related them correctly.
/// </summary>
///<param name="part">The art object to be removed from this objects collection.</param>
public virtual void Deletearts(art part)
{
if( part == null  ) throw new ArgumentNullException("part");
arts.Remove(part);
// Remove the Association with the Parent object
part.art_type = null;
}

/// <summary>
/// Add a new topRated object and automatically associate it with this instance as it's parent. This method makes easier to add new children and ensures you do not forget to related them correctly.
/// </summary>
///<param name="ptopRated">An topRated object to be added to this objects collection.</param>
public virtual void AddtopRated(topRated ptopRated)
{
if( ptopRated == null  ) throw new ArgumentNullException("ptopRated");
// Set the Parent Property
ptopRated.art_typeParent = this;
if (!ptopRated.IsValid) { throw new Exception("ptopRated failed on the Validate() method." + Error.ErrorsToString( ptopRated.Validate() ) ); }
topRateds.Add(ptopRated);
}

/// <summary>
/// Delete an existing topRated object + remove the association it with this instance as it's parent. This method makes easier to add new children and ensures you do not forget to related them correctly.
/// </summary>
///<param name="ptopRated">The topRated object to be removed from this objects collection.</param>
public virtual void DeletetopRateds(topRated ptopRated)
{
if( ptopRated == null  ) throw new ArgumentNullException("ptopRated");
topRateds.Remove(ptopRated);
// Remove the Association with the Parent object
ptopRated.art_typeParent = null;
}

/// <summary>
/// Validates the object returning a list of errors if the validation fails.
/// </summary>
/// <remarks>
/// You can use the provided User CodeBlocks to add your own validations.
/// </remarks>
///<returns>Returns the List of Errors found during the Validation. If no errors are found null is returned.<returns>
public virtual List<Error> Validate()
{
List<Error> _errors = new List<Error>();
return _errors;
}


#endregion


#region --- Class Events  ---

public event PropertyChangedEventHandler PropertyChanged 
{
   add {
_propertyChanged+= value;
   }
   remove {
_propertyChanged-= value;
   }
}


#endregion
}
}

